from sqlalchemy import Column, String, Text, Boolean

from database import db


class Metadata(db.Model):
    __table_name = 'metadata'
    id = Column(String(30), primary_key=True,autoincrement=True)
    screen_name = Column(String(200))
    type = Column(String(100))
    value_mode = Column(String(30), default='text')
    required = Column(Boolean(), default=True)
    extension = Column(Text(), nullable=True)


    VALUE_MODE_MUTI_SELECT = 'muti-select'
    VALUE_MODE_SELECT  = 'select'
    VALUE_MODE_TEXT = 'text'

    def is_muti_select(self):
        return self.value_mode == self.VALUE_MODE_MUTI_SELECT

    def is_select(self):
        return self.value_mode == self.VALUE_MODE_SELECT

    def is_text(self):
        return self.value_mode == self.VALUE_MODE_TEXT
#
#
# class MetadataValue(db.Model):
#     __table_name__ = 'metadata_value'
#     id = Column(Integer(), primary_key=True,autoincrement=True)
#     metadata_id = Column(ForeignKey('metadata.id'))
#     data_id = Column(String(120))
#     value = Column(String(400))
    # metadata = relationship(Metadata)

